import 'dart:io';

import 'package:dio/dio.dart';
import 'package:pretty_dio_logger/pretty_dio_logger.dart';

class BaseDio {
  BaseDio._();

  static BaseDio? _instance;

  static BaseDio? getInstance() {
    _instance ??= BaseDio._();

    return _instance;
  }

  Dio getDio() {
    final Dio dio = Dio();
    dio.options = BaseOptions(
        receiveTimeout: Duration(seconds: 10),
        connectTimeout: Duration(seconds: 10),
        sendTimeout: Duration(seconds: 10),
        baseUrl: "http://1.15.221.125:3000");
    dio.interceptors.add(PrettyDioLogger(
      requestHeader: true,
      requestBody: true,
      responseBody: true,
      responseHeader: false,
      compact: false,
    ));
    return dio;
  }
}
